var CryptoJS = require('crypto-js');

function decrypt(text) {
	text = (text + '').replace(/\n*$/g, '').replace(/\n/g, '');
	const SECRET_KEY = CryptoJS.enc.Utf8.parse('myappsecretkey');
	const SECRET_IV = CryptoJS.enc.Utf8.parse('myappsecretkey');
	let base64 = CryptoJS.enc.Base64.parse(text);
	let srcs = CryptoJS.enc.Base64.stringify(base64);
	const decrypt = CryptoJS.AES.decrypt(srcs, SECRET_KEY, {
		iv: SECRET_IV,
		mode: CryptoJS.mode.CBC,
		padding: CryptoJS.pad.ZeroPadding,
	});
	const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
	return decryptedStr;
}

module.exports = decrypt;
